SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vw_RegistroDeLiquidacionesPorNivel
AS
SELECT IdCAbeceradeLiquidacion,O.idOrganizaciones, O.Nombre, L.localidad, 
    CASE WHEN O.CUISE IN (9828, 9812, 9840, 9879, 9880, 9853, 
    9847, 9873, 9843) 
    THEN 'Privado Subvencionado (TP)' ELSE 'Privado Subvencionado Transferido (TT)'
     END AS Presupuesto,  VS2.Mes, VS2.Anio,
    EGB AS EGB,
    Polimodal AS Polimodal,
    Superior   AS Superior,
    AnexoI, 
    AnexoII AS  BLP,
    AnexoIII As ISS,
    ATransferir As ATransferir,
    VS2.Tipo As Tipo,
    EstimuloEGB+Estimulo2EGB as EstimuloEGB, EstimuloPOLIMODAL+Estimulo2POLIMODAL as EstimuloPOLIMODAL, EstimuloSUPERIOR+Estimulo2SUPERIOR as EstimuloSUPERIOR, TotalEstimulo+TotalEstimulo2 as TotalEstimulo 	
FROM tb_Organizaciones O 
INNER JOIN  tb_Localidades L ON L.idLocalidad = O.Localidad 
INNER JOIN  tb_ValoresDeSubsidios2 VS2 ON idOrganizaciones = Organizacion
INNER JOIN Tb_CabeceradeLiquidacion ON  IdCAbeceradeLiquidacion=CabeceradeLiquidacion
WHERE (O.EsPrivada = 'S' and Baja = 'N')













GO
GRANT SELECT ON  [dbo].[vw_RegistroDeLiquidacionesPorNivel] TO [SoloVer]
GO
